package cn.usts.edu.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//@Controller
//这里的controller容易导入错误不是【import org.springframework.stereotype.Controller】！！！！！！！;
public class HelloController implements Controller {
//    @RequestMapping("/hello")
//    public String hello(Model model){
//        model.addAttribute("msg","hello");
//        return "hello";

//   传统方式实现Controller
    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        ModelAndView mav = new ModelAndView();
        mav.addObject("msg","注意别把controller导入错了1");
        mav.setViewName("hello");
        return mav;
    }
}

//    @RequestMapping("/hello2")
//    public String hello2(Model model){
//        model.addAttribute("msg","hello2");
//        return "hello2";
//    }

